from Autotests.LocalMachine.Controls.Button import WebButton
from Autotests.LocalMachine.Controls.LineEdit import WebLineEdit
from Autotests.LocalMachine.Controls.CheckBox import WebDefaultCheckBox
from Autotests.LocalMachine.Controls.ComboBox import WebComboBox
from Autotests.LocalMachine.UiObjectsMap.AirClient import Options
from OptionsPage import OptionsPage


class SchedulePeriodicity(object):
    daily = 'Daily'
    wednesdayAndSaturday = 'WednesdayAndSaturday'
    saturday = 'Saturday'
    never = 'Never'
    weekly = 'Weekly'
    monthly = 'Monthly'


class GeneralTab(OptionsPage):
    def __init__(self):
        super(GeneralTab, self).__init__()
        self._mailAddressEdit = WebLineEdit(Options.General.txtboxMailAddress)
        self._comboBoxMailSendPeriodicity = WebComboBox(Options.General.cbMailSendPeriodicity)
        self._checkBoxRemoteConnection = WebDefaultCheckBox(Options.General.checkboxRemoteConnection)

    def goToHomeLocation(self):
        super(GeneralTab, self).goToHomeLocation()
        WebButton(Options.btnGeneral).click()

    @OptionsPage.setter
    def setGeneralSettings(self, mailAddress, remoteConnectionEnabled, periodicity):
        self._mailAddressEdit.typeText(mailAddress)
        self._checkBoxRemoteConnection.setCheckState(remoteConnectionEnabled)
        self._comboBoxMailSendPeriodicity.selectItemsByDataValue(periodicity)

    @OptionsPage.getter
    def getGeneralSettings(self):
        mailAddress = self._mailAddressEdit.text()
        isRemoteConnection = self._checkBoxRemoteConnection.isChecked()
        periodicity = self._comboBoxMailSendPeriodicity.currentItem().dataValue()
        return mailAddress, isRemoteConnection, periodicity


